﻿Imports System.Data.SqlClient
Public Class frmPadreMenores


    Private Sub frmPadreMenores_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Inhabilitamos los botones al inicio
        btnGuardar.Enabled = True
        btnEliminar.Enabled = False
        btnCancelar.Enabled = True
        txtDescripcion.Select()
        txtDescripcion.Focus()

    End Sub

    Private Sub tbcPadreMenores_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbcPadreMenores.SelectedIndexChanged
        Try
            Me.Cursor = Cursors.WaitCursor
            'Cuando se activa la pagina de Consulta se envia el foco al txtBusqueda
            If tbcPadreMenores.SelectedIndex = 1 Then
                txtBusqueda.Text = ""
                txtBusqueda.Select()
                btnCancelar.Enabled = False
                btnEliminar.Enabled = False
                btnGuardar.Enabled = False

            Else

                If txtCodigo.Text <> "" Then
                    btnEliminar.Enabled = True
                Else
                    btnEliminar.Enabled = False
                End If
                txtDescripcion.Select()
                btnCancelar.Enabled = True
                btnGuardar.Enabled = True
            End If
        Catch ex As Exception
            Me.Cursor = Cursors.Default
            MessageBox.Show(ex.Message, "Sistema PCS", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
            Me.Cursor = Cursors.WaitCursor
            'Habilitamos los botones 
            txtDescripcion.Enabled = True
            txtDescripcion.Select()
            btnGuardar.Enabled = True
            btnCancelar.Enabled = True
        Catch ex As Exception
            Me.Cursor = Cursors.Default
            MessageBox.Show(ex.Message, "Sistema PCS", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            Me.Cursor = Cursors.Default
        End Try

    End Sub

    Private Sub btnCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelar.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            'Inhabilitamos los botones al inicio
            btnGuardar.Enabled = True
            btnEliminar.Enabled = False
            txtCodigo.Text = ""
            txtDescripcion.Text = ""
            txtDescripcion.Select()
            vbNuevo = True
        Catch ex As Exception
            Me.Cursor = Cursors.Default
            MessageBox.Show(ex.Message, "Sistema PCS", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            Me.Cursor = Cursors.Default
        End Try

    End Sub

End Class